<!DOCTYPE html>
<html>
<head>
    <title>测试工单API</title>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</head>
<body>
    <h1>工单分配统计API测试</h1>
    <button onclick="setToken()">设置Token</button>
    <button onclick="testStats()">测试概览统计</button>
    <button onclick="testDepartmentStats()">测试部门统计</button>
    <button onclick="testEmployeeStats()">测试员工统计</button>
    <div id="result"></div>

    <script>
        const token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJvYS5nb3VndWNtcy5jb20iLCJhdWQiOiJnb3VndW9hIiwiaWF0IjoxNzYyNzM1NjUxLCJleHAiOjE3NjI4MjIwNTEsInN1YiI6MSwiZGF0YSI6eyJ1c2VyaWQiOjF9fQ.gNhF7_qCIsAWhGsJ_yQr_ot6uXEnM69ARcdrccCihZ8';
        
        function setToken() {
            localStorage.setItem('token', token);
            document.getElementById('result').innerHTML = 'Token已设置<br>';
        }

        async function testStats() {
            try {
                const response = await axios.get('http://localhost:8000/api/workorder/assignmentHistory/stats', {
                    headers: {
                        'Authorization': `Bearer ${token}`
                    }
                });
                document.getElementById('result').innerHTML += '概览统计: ' + JSON.stringify(response.data) + '<br>';
            } catch (error) {
                document.getElementById('result').innerHTML += '概览统计错误: ' + error.message + '<br>';
            }
        }

        async function testDepartmentStats() {
            try {
                const response = await axios.get('http://localhost:8000/api/workorder/assignmentHistory/departmentStats', {
                    headers: {
                        'Authorization': `Bearer ${token}`
                    }
                });
                document.getElementById('result').innerHTML += '部门统计: ' + JSON.stringify(response.data) + '<br>';
            } catch (error) {
                document.getElementById('result').innerHTML += '部门统计错误: ' + error.message + '<br>';
            }
        }

        async function testEmployeeStats() {
            try {
                const response = await axios.get('http://localhost:8000/api/workorder/assignmentHistory/employeeStats', {
                    headers: {
                        'Authorization': `Bearer ${token}`
                    }
                });
                document.getElementById('result').innerHTML += '员工统计: ' + JSON.stringify(response.data) + '<br>';
            } catch (error) {
                document.getElementById('result').innerHTML += '员工统计错误: ' + error.message + '<br>';
            }
        }
    </script>
</body>
</html>
